<%@ page import="entity.Commodity" %>
<%@ page import="entity.ShoppingCart" %><%--
  Created by IntelliJ IDEA.
  User: 浮犴兮
  Date: 2022/4/6
  Time: 20:35
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>商品详细信息页面</title>
    <style>
        table {
            margin: 80px auto 0 auto;
            border: 1px black solid;
            font-size: 24px;
            border-spacing: 0;
            border-top: 1px solid black;
            border-left: 1px solid black;
        }

        .tdStyle td {
            padding: 10px;
            border-right: 1px solid black;
            border-bottom: 1px solid black;
            border-collapse: collapse;
        }
    </style>
</head>
<body>
<script>
    function checkQuality() {
        var quanlity = document.getElementById("quality");
        var input_quality = quanlity.value;
        if (!/^[0-9]+$/.test(input_quality)) {
            alert("输入的条形码不是整数");
            quanlity.style.borderColor = "RED";
            document.getElementById("quality").value = "";
        } else {
            quanlity.style.borderColor = "BLACK";
        }
    }
</script>
<div style="padding-top:30px;padding-left: 35px">
    <a href="CommodityListController" style="color: #F45B4B;font-size: 24px">⬅返回首页</a>
</div>
<h1 align="center" style="padding-top: 60px">商品详细界面</h1>
<form action="/ShoppingCart" method="post">
    <table class="tdStyle">
        <%
            Commodity commodity = (Commodity) request.getAttribute("shop_commodity");
            String quality = request.getParameter("quality");
        %>
        <input type="hidden" name="cId" value="<%=commodity.getcId()%>">
        <tr>
            <td style="background-color: #F45B4B">商品条形码:</td>
            <td><%=commodity.getcId()%>
            </td>
        </tr>
        <tr>
            <td style="background-color: #F45B4B">商品名称:</td>
            <td><%=commodity.getcName()%>
            </td>
        </tr>
        <tr>
            <td style="background-color: #F45B4B">商品种类:</td>
            <td><%=commodity.getcKind().toString()%>
            </td>
        </tr>
        <tr>
            <td style="background-color: #F45B4B">商品价格:</td>
            <td><%=commodity.getcPrice()%>
            </td>
        </tr>
        <tr>
            <td style="background-color: #F45B4B">请输入您要购买的数量:</td>
            <td><input id="quality" onchange="checkQuality()" type="text" width="16px" style="font-size: 24px"
                       name="quality" required value="<%=quality==null?"":quality%>"></td>
        </tr>
    </table>
    <div align="center" style="padding-top: 60px">
        <input type="submit" size="24px" style="font-size: 24px">
    </div>
</form>
</body>
</html>
